/**
 * Copyright (C) 2009 Noel Ang
 *
 * This file is part of Samsara.
 *
 * Samsara is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Samsara is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Samsara.  If not, see <http://www.gnu.org/licenses/>.
 ******************************************************************************/
package com.lunarshades.samsara.ui.actions;

import com.lunarshades.samsara.Raider;
import com.lunarshades.samsara.logging.Loggable;

/**
 * Represents a karma modification.
 *
 * @author Noel Ang, sparta.variable@gmail.com
 */
public abstract class KarmaChangeEvent<T extends Raider> implements Loggable {

/**
 * Create a KarmaChangeEvent.
 *
 * @param subject The subject of the change.
 * @param amount  The magnitude of the change. Must be a zero or non-negative
 *                value.
 *
 * @throws NullPointerException     if subject is null.
 * @throws IllegalArgumentException if amount is a negative value.
 */
protected KarmaChangeEvent(T subject, int amount) {
    if (subject == null) {
        throw new NullPointerException("subject");
    }
    if (amount < 0) {
        throw new IllegalArgumentException("amount: " + amount);
    }
    mSubject = subject;
    mMagnitude = amount;
}

public T subject() {
    return mSubject;
}

public int magnitude() {
    return mMagnitude;
}

/**
 * @return A representative message.
 */
public abstract Object message();

private final T mSubject;
private final int mMagnitude;
}
